{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>题目审核</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal" name="add_cate" id="add_box" method="post" action="">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">题&nbsp;&nbsp;目：</label>
                            <div class="col-sm-4">
                                <input id="name" type="text" class="form-control" disabled="disabled" value="{$data['title']|default=''}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否通过</label>
                            <div class="col-sm-4">
                                <select id="status" name="status" class="form-control">
                                    <option value="">--请选择--</option>
                                    <option value="1" {:$data['status']==1?"selected":''}>通过</option>
                                    <option value="2" {:$data['status']==2?"selected":''}>不通过</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否好题</label>
                            <div class="col-sm-4">
                                <select id="is_best" name="is_best" class="form-control">
                                    <option value="">--请选择--</option>
                                    <option value="1" {:$data['is_best']==1?"selected":''}>好</option>
                                    <option value="2" {:$data['is_best']==2?"selected":''}>不好</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">说&nbsp;&nbsp;明：</label>
                            <div class="col-sm-4">
                                <input id="question_text" type="text" class="form-control" name="question_text" value="{$data.question_text|default=''}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">

    $(function(){
        $('#add_box').ajaxForm({
            beforeSubmit: checkForm,
            success: complete,
            dataType: 'json'
        });

        function checkForm(){
            if( '' == $.trim($('#status').val())){
                layer.msg('请选择是否通过',{icon:2,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }else if( '' == $.trim($('#is_best').val())){
                layer.msg('请选择是否好题',{icon:2,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }else if( '' == $.trim($('#question_text').val())){
                layer.msg('请输入说明',{icon:2,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }
        }

        function complete(data){
            if(data.code==1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    window.location.href="{:url('audit_question/index')}";
                });
            }else{
                console.log(data);
                layer.msg(data.msg, {icon: 5,time:1500,shade: 0.1});
                return false;   
            }
        }
     
    });
</script>
</body>
</html>